home *** CD-ROM | disk | FTP | other *** search
- Path: cs.tu-berlin.de!news
- From: Roman Lechtchinsky <wolfro@cs.tu-berlin.de>
- Newsgroups: comp.lang.c++
- Subject: Re: works in Borland but not in Microsuck Visual C++
- Date: Fri, 15 Mar 1996 03:48:33 +0100
- Organization: Technical University of Berlin
- Message-ID: <3148DA81.20F9@cs.tu-berlin.de>
- References: <4ia6h8$jes@news.vanderbilt.edu>
- NNTP-Posting-Host: 130.149.17.231
- Mime-Version: 1.0
- Content-Type: text/plain; charset=us-ascii
- Content-Transfer-Encoding: 7bit
- X-Mailer: Mozilla 2.0 (Win95; I)
-
- Bennett Haselton wrote:
- >
- > Dear Abby,
- >
- > The following program was written in completely standard C++
- > and should be portable across platforms. However, it only performs as
- > expected (i.e. sends two copies of 4 to the standard out stream) in Borland
- > C++; when compiled in MicroSUCK Visual C++, it outputs 4 followed by a random
- > integer in the thousands.
- >
- > #include <iostream.h>
- >
- > struct person {
- > int age;
- > };
- >
- > struct person* matchPerson( struct person* psnPtr )
- > {
- > struct person* ansPtr;
- > ansPtr->age = psnPtr->age;
-
- How about initializing the pointer? ansPtr can point anywhere so don't be
- surprised about the output you get.
-
- > cout << ansPtr->age;
- > cout << ansPtr->age;
- > return ansPtr;
- > };
- >
- > void main()
- > {
- > struct person myperson;
- > myperson.age = 4;
- > struct person* k = matchPerson( &myperson );
- > }
- >
- > i was using version 1.0 of Visual C++; i have no knowledge of whether later
- > Microsuck compilers are capable of handling a program like this properly.
- > Please avoid buying their products whenever possible if you have not already
- > resolved to do so.
- > Is there a further explanation of this anomaly which i did not come
- > across? As usual, great Microsuck jokes will be mailed to anyone who can
- > help. Thanks!
- >
- > Love,
- >
- > tm
- > -bennett
-
- When do I get the jokes? ;-)
-
- Bye
-
- Roman
-